# +--------------------------
# | User: zq                -
# | Version: python3.7      -
# | Time: 2020-03-16 20:07                
# +--------------------------'
import time
from selenium import webdriver

url = "https://www.acfun.cn/login/"
brower = webdriver.Chrome(
    executable_path="/Users/zhangqiang/Desktop/05-python/03-spider-learn/spider/csdn_spider/chromedriver")


def login():
    username = "454168610@qq.com"
    password = "zl4921272"

    username = "18325356880"
    password = "1223665666."

    # 进入页面
    brower.get(url)

    # 点击进入账号密码登录
    to_mima_ele = brower.find_element_by_xpath("//a[@id='login-account-switch']")
    to_mima_ele.click()

    time.sleep(2)

    # 找打账号,密码框
    username_ele = brower.find_element_by_xpath("//input[@id='ipt-account-login']")
    password_ele = brower.find_element_by_xpath("//input[@id='ipt-pwd-login']")

    # 写入账号密码
    username_ele.send_keys(username)
    password_ele.send_keys(password)

    # 点击登录
    submit_ele = brower.find_element_by_xpath("//div[@class='btn-login']")
    submit_ele.click()

    time.sleep(10)

    # 进入个人页签到
    to_center_ele = brower.find_element_by_xpath("//a[@class='user-avatar item']")
    to_center_ele.click()

    time.sleep(8)

    # 签到节点
    # qiandao_ele = brower.find_element_by_xpath("//*[@id='btn-sign-user']")
    # qiandao_ele.click()

    text_ele = brower.find_element_by_xpath("//*[@id='btn-sign-user']")
    text_ele.click()

if __name__ == "__main__":
    login()
